package com.saer.server.network.logica.mensajes;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;

import com.saer.server.network.red.MsjNotForMeException;

public class MensajePing extends Mensaje {

	public MensajePing() {
		tipo = "PING";
	}

	public static MensajePing fromByte(byte[] input) throws IOException,
			MsjNotForMeException {
		ByteArrayInputStream bs = new ByteArrayInputStream(input);
		DataInputStream in = new DataInputStream(bs);
		MensajePing msj = new MensajePing();

		String string_verif = in.readUTF();
		if (!string_verif.equals("SAER"))
			throw new MsjNotForMeException();

		in.readUTF();
		msj.setIDmensaje(in.readInt()); // ID msj
		msj.setIDorigen(in.readInt()); // ID org
		msj.setIDdestino(in.readInt()); // ID dest
		msj.setCuerpo(in.readUTF());

		return msj;
	}

}
